#include"RingQueue.hpp"

#include<unistd.h>

template<typename T>
void* Consumer(void* input)
{
    auto rq = static_cast<RingQueue<T>*>(input);
    while(true)
    {
        sleep(1);
        rq->Consume();
        std::cout << "Consume()!!!\n" ;
    }
    return nullptr;
}
 

template<typename T>
void* Producer(void* input)
{
    auto rq = static_cast<RingQueue<T>*>(input);
    while(true)
    {
        rq->Produce(1);
        std::cout << "Producer()!!!\n" ;
    }
    
    return nullptr;
}

int main()
{
    
    pthread_t tid1 = 0;
    pthread_t tid2 = 0;
    RingQueue<int>* rq = new RingQueue<int>;

    pthread_create(&tid1,nullptr,Consumer<int>,(void*)rq);


    pthread_create(&tid1,nullptr,Producer<int>,(void*)rq);

    while(true) { sleep(1); }

    pthread_join(tid1,nullptr);
    pthread_join(tid2,nullptr);
    return 0;
}


// 